﻿
using System;
using System.Data;
using System.Text;
using System.Data.SqlClient;
using Maticsoft.DBUtility;
using System.Collections.Generic;//Please add references
namespace NetDisk_WebService.DAL
{
	/// <summary>
	/// 数据访问类:NetDisk
	/// </summary>
	public partial class NetDisk
	{
		public NetDisk()
		{}
		

        #region webservice

        /// <summary>
        /// 测试数据库连接是否成功
        /// <creator>wangl</creator>
        /// <date>2013-02-17</date>
        /// </summary>
        /// <returns>
        /// 1 成功 
        /// -1 失败
        /// </returns>
        public int DBConnectTest()
        {
            StringBuilder strSql = new StringBuilder();
            strSql.Append("SELECT 1");
            object obj = DbHelperSQL.GetSingle(strSql.ToString());
            if (obj != null)
            {
                return 1;
            }
            else
            {
                return -1;
            }

        }

        /// <summary>
        /// 获取数据库服务器系统时间，返回的时间精度到毫秒
        /// 不为null ,如果数据库无法获取则取当前本地时间(2012-05-10 wangl 修改)
        /// <creator>wangl</creator>
        /// <date>2013-02-17</date> 
        /// </summary>
        /// <returns>null为获取失败</returns>
        public DateTime GetServerDatetime()
        {
            StringBuilder strSql = new StringBuilder();
            strSql.Append("SELECT GETDATE()");
            object obj = DbHelperSQL.GetSingle(strSql.ToString());
            if (obj != null)
            {
                // modify by wangzhubao 2012年3月4日
                //return DateTime.Parse(obj.ToString());   // 返回精度到秒
                return (DateTime)obj;           // 返回精度到毫秒
            }
            else
            {
                return DateTime.Now;
            }

        }


        /// <summary>
        /// 是否存在该记录
        /// <creator>sunlj</creator>
        /// <date>2014-11-24</date> 
        /// </summary>
        /// <param name="fLogID">用户登录号</param>
        /// <param name="fEntityNo">组织机构编号</param>
        /// <returns>是否存在</returns>
        public bool Exists(string fLogID, string fEntityNo)
        {
            StringBuilder strSql = new StringBuilder();
            strSql.Append("select count(1) from t_PrvUser");
            strSql.Append(" where FLogID=@FLogID and FEntityNo=@FEntityNo ");
            SqlParameter[] parameters = {
					new SqlParameter("@FLogID", SqlDbType.NVarChar,30),
					new SqlParameter("@FEntityNo", SqlDbType.NVarChar,12)			};
            parameters[0].Value = fLogID;
            parameters[1].Value = fEntityNo;

            return DbHelperSQL.Exists(strSql.ToString(), parameters);
        }

        /// <summary>
        /// 获取用户密码
        /// <creator>sunlj</creator>
        /// <date>2014-11-24</date> 
        /// </summary>
        /// <param name="logid">登录ID</param>
        /// <returns></returns>
        public string GetUserPassword(string logID, string FEntityNo)
        {
            StringBuilder strSql = new StringBuilder();
            strSql.Append("SELECT Fpassword FROM t_PrvUser");
            strSql.Append(" where FLogID=@FLogID and FEntityNo=@FEntityNo");
            SqlParameter[] parameters = {
					new SqlParameter("@FLogID", SqlDbType.NVarChar,30),
                    new SqlParameter("@FEntityNo",SqlDbType.NVarChar,12)};
            parameters[0].Value = logID;
            parameters[1].Value = FEntityNo;
            object obj = DbHelperSQL.GetSingle(strSql.ToString(), parameters);
            if (obj != null)
            {
                return obj.ToString();
            }
            else
            {
                return "";
            }
        }


        /// <summary>
        /// 获取用户名
        /// <creator>sunlj</creator>
        /// <date>2014-11-24</date> 
        /// </summary>
        /// <param name="logID">登录ID</param>
        /// <returns></returns>
        public string GetUserFullname(string logID, string FEntityNo)
        {
            StringBuilder strSql = new StringBuilder();
            strSql.Append("SELECT FUserName FROM t_PrvUser");
            strSql.Append(" where FLogID=@FLogID AND FEntityNo=@FEntityNo");
            SqlParameter[] parameters = {
					new SqlParameter("@FLogID", SqlDbType.NVarChar,30),
                    new SqlParameter("@FEntityNo",SqlDbType.NVarChar,12)
                                        };
            parameters[0].Value = logID;
            parameters[1].Value = FEntityNo;
            object obj = DbHelperSQL.GetSingle(strSql.ToString(), parameters);
            if (obj != null)
            {
                return obj.ToString();
            }
            else
            {
                return "";
            }
        }


        /// <summary>
        /// 增加一条数据
        /// </summary>
        public decimal AddNetDisk(Model.NetDisk model)
        {
            StringBuilder strSql = new StringBuilder();
            strSql.Append("insert into t_NetDisk(");
            strSql.Append("FParentID,FName,FSuffixName,FType,FSize,FDate,FLogID,FEntityNo,FMD5,FUploadMode)");
            strSql.Append(" values (");
            strSql.Append("@FParentID,@FName,@FSuffixName,@FType,@FSize,@FDate,@FLogID,@FEntityNo,@FMD5,'CS')");
            strSql.Append(";SELECT @returnId=IDENT_CURRENT('t_NetDisk') ");
            SqlParameter[] parameters = {
					new SqlParameter("@FParentID", SqlDbType.Decimal,13),
					new SqlParameter("@FName", SqlDbType.NVarChar,255),
					new SqlParameter("@FSuffixName", SqlDbType.NVarChar,20),
					new SqlParameter("@FType", SqlDbType.VarChar,1),
					new SqlParameter("@FSize", SqlDbType.Decimal,13),
					new SqlParameter("@FDate", SqlDbType.DateTime),
					new SqlParameter("@FLogID", SqlDbType.NVarChar,30),
					new SqlParameter("@FEntityNo", SqlDbType.NVarChar,12),
					new SqlParameter("@FMD5", SqlDbType.VarChar,32),
                    new SqlParameter("@returnId",SqlDbType.Decimal,9)
                                        };
            parameters[0].Value = model.FParentID;
            parameters[1].Value = model.FName;
            parameters[2].Value = model.FSuffixName;
            parameters[3].Value = model.FType;
            parameters[4].Value = model.FSize;
            parameters[5].Value = model.FDate;
            parameters[6].Value = model.FLogID;
            parameters[7].Value = model.FEntityNo;
            parameters[8].Value = model.FMD5;
            parameters[9].Direction = ParameterDirection.Output;

            DbHelperSQL.ExecuteSql(strSql.ToString(), parameters);
            return decimal.Parse(parameters[9].Value.ToString());
        }

        /// <summary>
        /// 增加一条数据（覆盖文件）
        /// <creator>sunlj</creator>
        /// <date>2014-12-12</date>
        /// </summary>
        public decimal AddNetDiskCover(Model.NetDisk model)
        {
            CommandInfo commandInfo = new CommandInfo();
            List<CommandInfo> commandInfoList = new List<CommandInfo>();
            StringBuilder strSql = new StringBuilder();
            SqlParameter[] parameters = new SqlParameter[] { };

            //先删除父文件夹下的相同文件
            strSql = new StringBuilder();
            strSql.Append("DELETE FROM dbo.t_NetDisk WHERE  FName=@FName AND FEntityNo=@FEntityNo and FParentID=@FParentID ");
            parameters = new SqlParameter[] { 
                    new SqlParameter("@FName",SqlDbType.NVarChar,255),
                    new SqlParameter("@FEntityNo",SqlDbType.NVarChar,12),
                    new SqlParameter("@FParentID",SqlDbType.Decimal,18)
            };
            parameters[0].Value = model.FName;
            parameters[1].Value = model.FEntityNo;
            parameters[2].Value = model.FParentID;
            commandInfo = new CommandInfo(strSql.ToString(), parameters);
            commandInfoList.Add(commandInfo);

            //再插入数据
            strSql = new StringBuilder();
            strSql.Append("insert into t_NetDisk(");
            strSql.Append("FParentID,FName,FSuffixName,FType,FSize,FDate,FLogID,FEntityNo,FMD5,FUploadMode)");
            strSql.Append(" values (");
            strSql.Append("@FParentID,@FName,@FSuffixName,@FType,@FSize,@FDate,@FLogID,@FEntityNo,@FMD5,'CS')");
            strSql.Append(";SELECT @returnId=IDENT_CURRENT('t_NetDisk') ");
            SqlParameter[] parameters1 = new SqlParameter[]{
					new SqlParameter("@FParentID", SqlDbType.Decimal,13),
					new SqlParameter("@FName", SqlDbType.NVarChar,255),
					new SqlParameter("@FSuffixName", SqlDbType.NVarChar,20),
					new SqlParameter("@FType", SqlDbType.VarChar,1),
					new SqlParameter("@FSize", SqlDbType.Decimal,13),
					new SqlParameter("@FDate", SqlDbType.DateTime),
					new SqlParameter("@FLogID", SqlDbType.NVarChar,30),
					new SqlParameter("@FEntityNo", SqlDbType.NVarChar,12),
					new SqlParameter("@FMD5", SqlDbType.VarChar,32),
                    new SqlParameter("@returnId",SqlDbType.Decimal,9)
                                        };
            parameters1[0].Value = model.FParentID;
            parameters1[1].Value = model.FName;
            parameters1[2].Value = model.FSuffixName;
            parameters1[3].Value = model.FType;
            parameters1[4].Value = model.FSize;
            parameters1[5].Value = model.FDate;
            parameters1[6].Value = model.FLogID;
            parameters1[7].Value = model.FEntityNo;
            parameters1[8].Value = model.FMD5;
            parameters1[9].Direction = ParameterDirection.Output;
            commandInfo = new CommandInfo(strSql.ToString(), parameters1);
            commandInfoList.Add(commandInfo);

            if (commandInfoList.Count > 0)
            {
                DbHelperSQL.ExecuteSqlTranWithIndentity(commandInfoList);
                return decimal.Parse(parameters1[9].Value.ToString());
            }
            else
            {
                return 0;
            }
        }

        /// <summary>
        /// 获取网盘列表
        /// <create>sunlj</create>
        /// <date>2014-12-08</date>
        /// </summary>
        /// <param name="FParentID"></param>
        /// <param name="entityNo"></param>
        /// <param name="orderField"></param>
        /// <returns></returns>
        public DataSet GetList(decimal FParentID, string entityNo, string orderField)
        {
            StringBuilder strSql = new StringBuilder();
            strSql.Append(@"SELECT  FID ,
        FParentID ,
        FName ,
        FSuffixName ,
        FType ,
        FSize ,
        FDate ,
        FLogID ,
        FEntityNo ,
        FMD5 FROM dbo.t_NetDisk WHERE FParentID=@FParentID AND FEntityNo=@FEntityNo");
            if (orderField != "")
            {
                strSql.Append(" ORDER BY " + orderField);
            }
            SqlParameter[] parameters = new SqlParameter[] {
                    new SqlParameter("@FParentID",SqlDbType.Decimal,18),
                    new SqlParameter("@FEntityNo",SqlDbType.NVarChar,12)
            };
            parameters[0].Value = FParentID;
            parameters[1].Value = entityNo;

          return DbHelperSQL.Query(strSql.ToString(), parameters);
        }

        /// <summary>
        /// 获取网盘列表
        /// <create>sunlj</create>
        /// <date>2014-12-08</date>
        /// </summary>
        /// <param name="strWhere"></param>
        /// <param name="entityNo"></param>
        /// <returns></returns>
        public DataSet GetModelList(string strWhere, string entityNo)
        {
            StringBuilder strSql = new StringBuilder();
            strSql.Append(@"SELECT  FID ,
        FParentID ,
        FName ,
        FSuffixName ,
        FType ,
        FSize ,
        FDate ,
        FLogID ,
        FEntityNo ,
        FMD5 FROM dbo.t_NetDisk WHERE FEntityNo=@FEntityNo ");
            if (strWhere != "")
            {
                strSql.Append(" and "+strWhere);
            }
           
            SqlParameter[] parameters = new SqlParameter[] {
                    new SqlParameter("@FEntityNo",SqlDbType.NVarChar,12)
            };
            parameters[0].Value = entityNo;

            return DbHelperSQL.Query(strSql.ToString(), parameters);
        }

        /// <summary>
        /// 获取网盘列表(递归)
        /// <create>sunlj</create>
        /// <date>2014-12-08</date>
        /// </summary>
        /// <param name="FParentID"></param>
        /// <param name="entityNo"></param>
        /// <param name="orderField"></param>
        /// <returns></returns>
        public DataSet GetListCTE(decimal FParentID, string entityNo,string strWhere, string orderField)
        {
            StringBuilder strSql = new StringBuilder();
            strSql.Append(@"SELECT  FID ,
        FParentID ,
        FName ,
        FSuffixName ,
        FType ,
        FSize ,
        FDate ,
        FLogID ,
        FEntityNo ,
        FMD5 FROM dbo.fn_NetDisk(@FParentID,@FEntityNo) ");
            if (strWhere != "")
            {
                strSql.Append(" where " + strWhere);
            }
            if (orderField != "")
            {
                strSql.Append(" ORDER BY " + orderField);
            }
            SqlParameter[] parameters = new SqlParameter[] {
                    new SqlParameter("@FParentID",SqlDbType.Decimal,18),
                    new SqlParameter("@FEntityNo",SqlDbType.NVarChar,12)
            };
            parameters[0].Value = FParentID;
            parameters[1].Value = entityNo;

            return DbHelperSQL.Query(strSql.ToString(), parameters);
        }

        /// <summary>
        /// 得到一个对象实体
        /// </summary>
        public Model.NetDisk DataRowToModel(DataRow row)
        {
            Model.NetDisk model = new Model.NetDisk();
            if (row != null)
            {
                if (row["FID"] != null && row["FID"].ToString() != "")
                {
                    model.FID = decimal.Parse(row["FID"].ToString());
                }
                if (row["FParentID"] != null && row["FParentID"].ToString() != "")
                {
                    model.FParentID = decimal.Parse(row["FParentID"].ToString());
                }
                if (row["FName"] != null)
                {
                    model.FName = row["FName"].ToString();
                }
                if (row["FSuffixName"] != null)
                {
                    model.FSuffixName = row["FSuffixName"].ToString();
                }
                if (row["FType"] != null)
                {
                    model.FType = row["FType"].ToString();
                }
                if (row["FSize"] != null && row["FSize"].ToString() != "")
                {
                    model.FSize = decimal.Parse(row["FSize"].ToString());
                }
                if (row["FDate"] != null && row["FDate"].ToString() != "")
                {
                    model.FDate = DateTime.Parse(row["FDate"].ToString());
                }
                if (row["FLogID"] != null)
                {
                    model.FLogID = row["FLogID"].ToString();
                }
                if (row["FEntityNo"] != null)
                {
                    model.FEntityNo = row["FEntityNo"].ToString();
                }
                if (row.Table.Columns.Contains("FMD5"))
                {
                    if (row["FMD5"] != null)
                    {
                        model.FMD5 = row["FMD5"].ToString();
                    }
                }
                if (row.Table.Columns.Contains("FUploadMode"))
                {
                    if (row["FUploadMode"] != null)
                    {
                        model.FUploadMode = row["FUploadMode"].ToString();
                    }
                }
            }
            return model;
        }


        /// <summary>
        /// 获得数据列表
        /// <creator>sunlj</creator>
        /// <date>2014-10-27</date>
        /// </summary>
        public DataSet GetDirByFLogID(string FEntityNo, string FLogID)
        {
            StringBuilder strSql = new StringBuilder();
            strSql.Append(@"SELECT  FID ,
        FParentID ,
        FName ,
        FSuffixName ,
        FType ,
        FSize ,
        FDate ,
        FLogID ,
        FEntityNo,
        FMD5 FROM dbo.t_NetDisk WHERE FType='D' AND FEntityNo=@FEntityNo AND FLogID=@FLogID");
            SqlParameter[] paramters = { 
                        new SqlParameter("@FEntityNo",SqlDbType.NVarChar,12),
                        new SqlParameter("@FLogID",SqlDbType.NVarChar,30)
                                       };
            paramters[0].Value = FEntityNo;
            paramters[1].Value = FLogID;
            return DbHelperSQL.Query(strSql.ToString(), paramters);
        }

        /// <summary>
        /// 同一路径下的相同文件夹
        /// <creator>sunlj</creator>
        /// <date>2014-12-12</date>
        /// </summary>
        /// <param name="FParentID"></param>
        /// <param name="FName"></param>
        /// <param name="FEntityNo"></param>
        /// <returns></returns>
        public decimal GetSame(decimal FParentID, string FName, string FEntityNo, string oldFID)
        {
            StringBuilder strSql = new StringBuilder();
            strSql.Append("SELECT FID FROM dbo.t_NetDisk WHERE FName=@FName AND FEntityNo=@FEntityNo and FParentID=@FParentID ");

            if (oldFID != "")
            {
                strSql.Append(" and FID!=" + oldFID);
            }

            SqlParameter[] parameters = { 
                        new SqlParameter("@FName",SqlDbType.NVarChar,255),
                        new SqlParameter("@FEntityNo",SqlDbType.NVarChar,12),
                        new SqlParameter("@FParentID",SqlDbType.Decimal)
                                        };
            parameters[0].Value = FName;
            parameters[1].Value = FEntityNo;
            parameters[2].Value = FParentID;
            object obj= DbHelperSQL.GetSingle(strSql.ToString(), parameters);
            if (obj == null)
            {
                return 0;
            }
            else
            {
                return decimal.Parse(obj.ToString());
            }
        }

        /// <summary>
        /// 判断是否将当前文件夹移动到它的子文件夹
        /// </summary>
        /// <param name="FParentID"></param>
        /// <param name="FID"></param>
        /// <param name="FEntityNo"></param>
        /// <returns></returns>
        public bool IsErrorMoveParentDirChildDir(decimal FParentID,decimal FID,string FEntityNo)
        {

            StringBuilder strSql = new StringBuilder();
            strSql.Append("SELECT * from  dbo.fn_GetNetDisk_Pre(@FID) WHERE FID=@FParentID AND FEntityNo=@FEntityNo");
            SqlParameter[] parameters = { 
                        new SqlParameter("@FID",SqlDbType.Decimal),
                        new SqlParameter("@FEntityNo",SqlDbType.NVarChar,12),
                        new SqlParameter("@FParentID",SqlDbType.Decimal)
                                        };
            parameters[0].Value = FID;
            parameters[1].Value = FEntityNo;
            parameters[2].Value = FParentID;

            return DbHelperSQL.Exists(strSql.ToString(),parameters);
        }
        /// <summary>
        /// 获取当前目录的所有父级目录
        /// <creator>sunlj</creator>
        /// <date>2014-09-25</date>
        /// </summary>
        /// <param name="id"></param>
        /// <returns></returns>
        public DataSet GetListPre(decimal id)
        {
            StringBuilder strSql = new StringBuilder();
            strSql.Append(@"SELECT  FID ,
        FParentID ,
        FName ,
        FSuffixName ,
        FType ,
        FSize ,
        FDate ,
        FLogID ,
        FEntityNo ,
        FMD5 ,
        idLevel FROM dbo.fn_GetNetDisk_Pre(@FID)
        ORDER BY idLevel");
            SqlParameter[] parameters = { 
                            new SqlParameter("@FID",SqlDbType.Decimal)
                                        };
            parameters[0].Value = id;
            return DbHelperSQL.Query(strSql.ToString(), parameters);
        }

        /// <summary>
        /// 删除目录
        /// <creator>sunlj</creator>
        /// <date>2014-09-22</date>
        /// </summary>
        /// <param name="id"></param>
        public void deleteNetDisk(decimal id, string entityNo)
        {
            StringBuilder strSql = new StringBuilder();
            strSql.Append("DELETE FROM dbo.t_NetDisk WHERE FID=@FID AND FEntityNo=@FEntityNo ");
            SqlParameter[] parameters = {
					new SqlParameter("@FID", SqlDbType.Decimal),
                    new SqlParameter("@FEntityNo",SqlDbType.NVarChar,12)
			};
            parameters[0].Value = id;
            parameters[1].Value = entityNo;

            DbHelperSQL.ExecuteSql(strSql.ToString(), parameters);
        }


        /// <summary>
        /// 得到一个对象实体
        /// <creator>sunlj</creator>
        /// <date>2014-09-22</date>
        /// </summary>
        public Model.NetDisk GetModel(decimal FID)
        {
            StringBuilder strSql = new StringBuilder();
            strSql.Append("select  top 1 FID,FParentID,FName,FSuffixName,FType,FSize,FDate,FLogID,FEntityNo,FMD5 from t_NetDisk ");
            strSql.Append(" where FID=@FID");
            SqlParameter[] parameters = {
					new SqlParameter("@FID", SqlDbType.Decimal)
			};
            parameters[0].Value = FID;

            Model.NetDisk model = new Model.NetDisk();
            DataSet ds = DbHelperSQL.Query(strSql.ToString(), parameters);
            if (ds.Tables[0].Rows.Count > 0)
            {
                return DataRowToModel(ds.Tables[0].Rows[0]);
            }
            else
            {
                return null;
            }
        }

        /// <summary>
        /// 移动文件位置
        /// <creator>sunlj</creator>
        /// <date>2014-09-30</date>
        /// </summary>
        /// <param name="FID"></param>
        /// <param name="newParentID"></param>
        public void moveNetDisk(decimal FID, decimal newParentID)
        {
            StringBuilder strSql = new StringBuilder();
            strSql.Append("UPDATE t_NetDisk SET FParentID=@FParentID,FUploadMode='CS' WHERE FID=@FID");
            SqlParameter[] parameters = { 
                        new SqlParameter("@FParentID",SqlDbType.Decimal),
                        new SqlParameter("@FID",SqlDbType.Decimal)
                                        };
            parameters[0].Value = newParentID;
            parameters[1].Value = FID;
            DbHelperSQL.ExecuteSql(strSql.ToString(), parameters);
        }

        /// <summary>
        /// 重命名
        /// <creator>sunlj</creator>
        /// <date>2014-09-30</date>
        /// </summary>
        /// <param name="FID"></param>
        /// <param name="FName"></param>
        public void renameNetDisk(decimal FID, string FName)
        {
            StringBuilder strSql = new StringBuilder();
            strSql.Append("UPDATE dbo.t_NetDisk SET FName=@FName,FUploadMode='CS' WHERE FID=@FID");
            SqlParameter[] parameters = { 
                        new SqlParameter("@FName",SqlDbType.NVarChar,255),
                        new SqlParameter("@FID",SqlDbType.Decimal)
                                        };
            parameters[0].Value = FName;
            parameters[1].Value = FID;
            DbHelperSQL.ExecuteSql(strSql.ToString(), parameters);
        }

        /// <summary>
        /// 获取根目录
        /// <creator>sunlj</creator>
        /// <date>2014-12-18</date>
        /// </summary>
        /// <param name="logId"></param>
        /// <param name="entityNo"></param>
        /// <returns></returns>
        public Model.NetDisk GetRoot(string logId,string entityNo)
        {
            StringBuilder strSql = new StringBuilder();
            strSql.Append(@"SELECT TOP 1  FID ,
        FParentID ,
        FName ,
        FSuffixName ,
        FType ,
        FSize ,
        FDate ,
        FLogID ,
        FEntityNo ,
        FMD5 FROM dbo.t_NetDisk WHERE FParentID IS NULL AND FName=@FName AND FEntityNo=@FEntityNo ");
            SqlParameter[] parameters = {
					new SqlParameter("@FName", SqlDbType.NVarChar,255),
                    new SqlParameter("@FEntityNo", SqlDbType.NVarChar,12)
			};
            parameters[0].Value = logId;
            parameters[1].Value = entityNo;

            Model.NetDisk model = new Model.NetDisk();
            DataSet ds = DbHelperSQL.Query(strSql.ToString(), parameters);
            if (ds.Tables[0].Rows.Count > 0)
            {
                return DataRowToModel(ds.Tables[0].Rows[0]);
            }
            else
            {
                return null;
            }
        }

        /// <summary>
        /// 获取有子文件的文件夹
        /// <creator>sunlj</creator>
        /// <date>2015-1-30</date>
        /// </summary>
        /// <param name="entityNo"></param>
        /// <param name="ids"></param>
        /// <returns></returns>
        public DataSet GetDirectoryHaveChild(string entityNo,string ids)
        {
            StringBuilder strSql = new StringBuilder();
            strSql.Append(@"SELECT  FID ,
        FParentID ,
        FName ,
        FSuffixName ,
        FType ,
        FSize ,
        FDate ,
        FLogID ,
        FEntityNo ,
        FMD5 ,
        FUploadMode FROM dbo.t_NetDisk WHERE FID IN 
(");
            strSql.Append("SELECT DISTINCT FParentID FROM dbo.t_NetDisk WHERE FEntityNo=@FEntityNo AND FParentID IN (" + ids + ")");
            strSql.Append(")");
            SqlParameter[] parameters = { 
                            new SqlParameter("@FEntityNo",SqlDbType.NVarChar,12)
                                        };
            parameters[0].Value = entityNo;
            DataSet ds= DbHelperSQL.Query(strSql.ToString(), parameters);

            return ds;
        }

        #endregion
    }
}

